-
Notifications
You must be signed in to change notification settings - Fork 125
Make the ResponseAccumulator Sendable #838
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Make the ResponseAccumulator Sendable #838
Conversation
Motivation: The response accumulator is a delegate which must be sendable as it's passed across isolation domains. Modifications: - Make delegates have a sendable requirement - Make the response accumulator sendable Result: Delegates, and the response accumulator, are sendable
if self.requestMethod != .HEAD, | ||
let contentLength = head.headers.first(name: "Content-Length"), | ||
let announcedBodySize = Int(contentLength), | ||
announcedBodySize > self.maxBodySize |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Can I suggest that we pull this computation out of the lock?
@@ -894,30 +910,35 @@ extension HTTPClient { | |||
/// | |||
/// Will be created by the library and could be used for obtaining | |||
/// `EventLoopFuture<Response>` of the execution or cancellation of the execution. | |||
public final class Task<Response> { | |||
@preconcurrency | |||
public final class Task<Response: Sendable> { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Is the unchecked Sendable still needed for this? Can it be checked?
} | ||
} | ||
|
||
private var _isCancelled: Bool = false | ||
private var _taskDelegate: HTTPClientTaskDelegate? | ||
private let lock = NIOLock() | ||
private let makeOrGetFileIOThreadPool: () -> NIOThreadPool |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Looks like this needs an @Sendable
.
@@ -894,30 +910,35 @@ extension HTTPClient { | |||
/// | |||
/// Will be created by the library and could be used for obtaining | |||
/// `EventLoopFuture<Response>` of the execution or cancellation of the execution. | |||
public final class Task<Response> { | |||
@preconcurrency | |||
public final class Task<Response: Sendable> { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Also, how sure are we that this constraint is needed?
Motivation:
The response accumulator is a delegate which must be sendable as it's passed across isolation domains.
Modifications:
Result:
Delegates, and the response accumulator, are sendable